package com.mk.cloud.common.interceptor.cookie;

import act.app.ActionContext;
import com.alibaba.fastjson.JSON;
import com.mk.cloud.common.domain.CpUser;
import com.mk.cloud.common.enums.GlobalValues;
import com.mk.cloud.common.util.CookieUtil;
import org.osgl.inject.ValueLoader;
import org.osgl.util.S;import com.mk.cloud.common.util.S2;

public class CookieLoginUserFinder extends ValueLoader.Base {
    @Override
    public Object get() {
        ActionContext context = ActionContext.current();
        if (context != null) {
            String cookie = CookieUtil.getCookie(GlobalValues.COOKIE_KEYUSER.value(), context);
            if (S.isNotBlank(cookie)) {
                return JSON.parseObject(cookie, CpUser.class);
            }
        }
        return null;
    }

}
